<template>
  <div>
    <el-form :model="form" :rules="rules" ref="form" label-width="120px">
      <el-form-item label="描述" prop="mdStr">
        <MarkdownEditor  v-model="form.mdStr" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm('form')">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import MarkdownEditor from '@/components/MarkdownEditor.vue';

export default {
  components: {
    MarkdownEditor
  },
  data() {
    return {
      form: {
        mdStr: ''
      },
      rules: {
        mdStr: [
          { required: true, message: '请输入内容', trigger: 'blur' }
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.form.mdStr)
          alert('提交成功!');
        } else {
          console.log('验证失败!');
          return false;
        }
      });
    }
  }
};
</script>

<style scoped>
/* 添加一些样式 */
</style>
